package com.hy.erp.inventory.service;

import java.util.List ;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

/*import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
import org.jboss.seam.async.Schedule ;
*/
import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.PositionTypeDao;
import com.hy.erp.inventory.dao.RoleTypeDao;
import com.hy.erp.inventory.dao.interfaces.IRoleTypeDao;
import com.hy.erp.inventory.dao.interfaces.IUserDao;
import com.hy.erp.inventory.pojo.RoleType;
import com.hy.erp.inventory.pojo.interfaces.IRoleType;
import com.hy.erp.inventory.pojo.interfaces.IUser;
import com.hy.erp.inventory.service.interfaces.IRoleTypeService;
/**
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-10-12；时间：下午03:48:54</li>
 * <li>字段类型：long；字段名称：serialVersionUID</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
/*@Name("roleTypeService")
@Scope(ScopeType.SESSION)
@Stateless*/
@Component("roleTypeService")
public class RoleTypeService
							extends
							AbstractBusinessService < RoleTypeDao >
																	implements
																	IRoleTypeService
{

	
	private static final long	serialVersionUID	=
														- 7572148067051025599L ;

	private IRoleTypeDao roleTypeDao=null;
	
	

	@Resource(name="roleTypeDao")
	public void setPositionTypeDao(IRoleTypeDao roleTypeDao) {
		this.roleTypeDao = roleTypeDao;
	}
	/**
	 * 
	 * 构造函数
	 */
	public RoleTypeService()
	{
		super ( );
	}
	
	@ Override
	public boolean addRoleType (
									RoleType roleType )
	{
		if(roleType==null)
		{
			return true;
		}
		else
		{
			//IRoleTypeDao dao=( IRoleTypeDao ) this.getDao ( IRoleType.class );
			//IRoleType iRoleType= roleType;
			return roleTypeDao.persist ( roleType ) ;
		}
	}

	@ Override
	public Integer romoveRoleType (
									String[] typeIds )
	{
		if ( ( null == typeIds )
			     || ( typeIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{
				//IRoleTypeDao dao=( IRoleTypeDao ) this.getDao ( IRoleType.class );
				return roleTypeDao.remove ( typeIds );
			}
	}

	@ SuppressWarnings ( "unused" )
	@ Override
	public boolean modifyRoleType (
									RoleType roleType )
	{
		if ( ( null == roleType ) || ( null == roleType.getIdentifier ( ) ))
		{
			return true;
		}
		else
		{
			//IRoleTypeDao dao=( IRoleTypeDao ) this.getDao ( IRoleType.class );
			//IRoleType iRoleType= roleType;
			
			if ( null == roleType )
			{
				throw new ArchitectureFoundationException (
				                                            "修改用户实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}
			return (roleTypeDao
					.merge ( roleType )!=null) ;
		}
		
	}

	@ Override
	public String [ ] addRoleType (
									Object [ ] objects )
	{
		//IRoleTypeDao dao=( IRoleTypeDao ) this.getDao ( IRoleType.class );
		RoleType[] types=new RoleType[objects.length];
		for ( int i =
						0 ; i < objects.length ; i ++ )
		{
			RoleType roleType=( RoleType ) objects[i];
			types[i]=roleType;
		}
		return roleTypeDao.persist ( types ) ;
	}

	@ Override
	public List < RoleType > getAllRoleType ( )
	{
		//IRoleTypeDao dao=( IRoleTypeDao ) this.getDao ( IRoleType.class );
		return roleTypeDao.find ( ) ;
	}

	@ Override
	public String [ ] modifyRoleType (
										Object [ ] objects )
	{
		if (  null == objects ) 
		{
			return null;
		}
		else
		{
			//IRoleTypeDao dao=( IRoleTypeDao ) this.getDao ( IRoleType.class );
			RoleType[] types=new RoleType[objects.length];
            for(int i=0;i<objects.length;i++)
            {
            	RoleType type=( RoleType ) objects[i];
            	types[i]=type;
            }
			
			return roleTypeDao.merge ( types );
		}
	}

}
